<?php
if(empty($_GET['ip'])){
    $IP=$_SERVER['REMOTE_ADDR'];
}else{
	$IP=$_GET['ip'];
}
exec("sudo vtysh -c \"sh ip bgp $IP\"",$info);
$arr = explode(" ",$info[0]); 
$CDIR=end($arr);
if(strstr($CDIR,"table")) {
$ASN="null";
}elseif(strstr($CDIR,"0.0.0.0")) {
$ASN="null";
}
else
{
$arr1 = explode(" ",$info[3]); 
$ASN=end($arr1);
echo $CDIR." ".$ASN;
}
?>
